﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyVoteMVC.Domain.VT_Activities>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    活动详细
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="title">
        <h1>
            <%= Model.Activity_Title %><span></span></h1>
        <p>
            <%= Model.Activity_Content %></p>
    </div>
    <ul id="filter">
        <li>按项目年份：
            <label>
                <input type="radio" name="year" value="all" checked="checked">全部</label>
            <% foreach (string year in (List<string>)ViewData["yearList"])
               { %>
            <label>
                <input type="radio" name="year" value="<%= year %>"><%= year%></label>
            <%} %>
        </li>
        <li>按项目类型：
            <label>
                <input type="radio" name="type" value="all" checked="checked">全部</label>
            <% foreach (string type in (List<string>)ViewData["typeList"])
               { %>
            <label>
                <input type="radio" name="type" value="<%= type %>"><%= type%></label>
            <%} %>
        </li>
    </ul>
    <div>
        <%foreach (VT_Questions pQuestion in Model.Questions)
          {
              Html.RenderPartial("ProjectGrid", pQuestion);
          } %>
    </div>
    <div id="result">
        <ul class="splitter">
            <li>
                <% if ((bool)ViewData["ticketSubmit"])
                   {%>
                <button class="t-button" onclick="submitTicket()">
                    提交</button>
                <button class="t-button" onclick="saveTicket()">
                    保存</button><%}
                   else
                   {%>&nbsp; <a class="t-button" target="_blank" href="<%= Url.Action("VoteResult","Home",new {id = ViewContext.RouteData.Values["ID"].ToString()}) %>">
                       查看结果</a>
                <%} %></li>
        </ul>
    </div>
    <script type="text/javascript">
        function onRowSelect(e) {
            var row = e.row;
            var ItemID = e.row.cells[0].innerHTML;
            var pid = $('input:checkbox', row).eq(0).attr("pid");
            $('#projectInfo').fadeOut();
            $('#projectInfo').load('<%= Url.Action("ProjectInfoByItemId","Project") %>', ItemID);
            $('#projectInfo').fadeIn();
//            $.post("/home/ProjectById/" + pid, function (response) {
//                $('#projectInfo').html(response);
//                
//            });
        }

        function saveTicket() {
            var $checkedRecords = $(':checked');
            if ($checkedRecords.length < 1) {
                alert('您还没有选择');
                return;
            }
            $('#result').load('<%= Url.Action("SaveTicket", "Grid") %>', $checkedRecords);
            return true;
        }

        function submitTicket() {
            var $checkedRecords = $(':checked');
            if ($checkedRecords.length < 1) {
                alert('您还没有选择');
                return;
            }
            $('#result').load('<%= Url.Action("SubmitTicket", "Grid") %>', $checkedRecords);
        }

        if ('<%= TempData["ModelErrorMsg"] %>' != '') {
            alert('<%= TempData["ModelErrorMsg"] %>');
        }

        $('#filter input').change(function (e) {
            var $selecttype = $('#filter input[name="type"]:checked').val();
            var $selectyear = $('#filter input[name="year"]:checked').val();
            var table = $('#detailtable');
            var rows = $('tr', table);
            rows.each(function (index) {
                if (index > 0) {
                    if ($selecttype == 'all' && $selectyear == 'all') {
                        $(this).show();
                    }
                    else if ($selecttype == 'all' && $selectyear != 'all') {
                        if ($("td", this).eq(4).text() == $selectyear) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    }
                    else if ($selecttype != 'all' && $selectyear == 'all') {
                        if ($("td", this).eq(3).text() == $selecttype) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    } else {
                        if ($("td", this).eq(3).text() == $selecttype && $("td", this).eq(4).text() == $selectyear) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    }
                }
            });
        });
        $(function () {
            $.fancybox.helpers.buttons = {
                tpl: '<div id="fancybox-buttons"><ul><li><a class="btnClose" title="关闭" href="javascript:$.fancybox.close();">Close</a></li></ul></div>'
            }
        });
    
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
